package IEFYP.JunkCallFiltering;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
/**
 *  1. Call prompt time
 *  
 * @author KOLee
 * <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/r_prompt"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="80dip"
    android:text="Report"
   	android:textSize="20sp"
    android:layout_centerHorizontal="true"
    />
 */
public class ReportPrompt extends Activity {
	//static boolean success;
	static String Number;
	@Override
    public void onCreate(Bundle savedInstanceState) {
	
        super.onCreate(savedInstanceState);
		setContentView(R.layout.prompt);
		openOptionsDialog(ReportPrompt.this);
	//	Bundle bundle = this.getIntent().getExtras();
	//	 Number =  bundle.getString("IncommingCall");
		//Toast.makeText(getApplicationContext(),"trying",Toast.LENGTH_LONG).show();
       /* try{
        setContentView(R.xml.actionpref);
        }catch(Exception e){
        	Toast.makeText(getApplicationContext(), e.toString(),Toast.LENGTH_LONG);
        }
        */
	}
	
    public static void launch(Context mCon) { //Cannot Create by receiver,need to create by itself
    //	success = false;
    	Intent prompt = new Intent(mCon,ReportPrompt.class);  	
    	// Bundle bundle = new Bundle();
    	// bundle.putString("IncommingCall", InNumber);
    	prompt.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION);
    	mCon.startActivity(prompt);
    	
    }
    
    @Override
    protected void onStop() {
    		
            super.onStop();

            Log.i("prompt onStop","verifying success");
            //We are sneaky.
          //  if(!success){
         //   	ReportPrompt.launch(getApplicationContext());
         //   	success = true;
         //   }
           finish();

    }
    
   
    
	 private void openOptionsDialog(Context context){
		   	
		  
	   	 new AlertDialog.Builder(context)        //Menu is the activity name
	   	 .setTitle("Warning")
	   	 .setMessage("This is a suspecious/junk call\nDo you want to report?")
	   	  .setPositiveButton("Yes",
	                               new DialogInterface.OnClickListener(){
	                                       public void onClick(DialogInterface dialoginterface, int i){
	                                    	   Intent report = new Intent( ReportPrompt.this,ReportJunkCall.class); 
	                                    	   Bundle bundle = new Bundle();
	                                    	   bundle.putBoolean("FromPrompt", true);
	                                    	   report.putExtras(bundle);
	                                    	   startActivity(report);
	                                       }
	                               })
	         .setNegativeButton("No", new DialogInterface.OnClickListener() {
				
				public void onClick(DialogInterface dialog, int i) {
					 finish();
				}
			})          
	   	 .show();
	   
	    }
	    
}
